/*
 * TransactionSearchOptions.java
 */

package nxtgeninventorysystem.Data;

/**
 * The TransactionSearchOptions class is meant to hold data that will
 * determine which attributes will be filtered in transaction searches.
 * @author Seraph Softworks
 */
public class TransactionSearchOptions extends Data {

    private boolean consider_id;
    private boolean consider_type;
    private boolean consider_date;
    private boolean consider_purpose;
    private ItemSearchOptions consider_item;
    private PersonSearchOptions consider_person;

    /**
     * @return the consider_id
     */
    public boolean considerId() {
        return consider_id;
    }

    /**
     * @param consider_id the consider_id to set
     */
    public void setConsiderId(boolean consider_id) {
        this.consider_id = consider_id;
    }

    /**
     * @return the consider_type
     */
    public boolean considerType() {
        return consider_type;
    }

    /**
     * @param consider_type the consider_type to set
     */
    public void setConsiderType(boolean consider_type) {
        this.consider_type = consider_type;
    }

    /**
     * @return the consider_date
     */
    public boolean considerDate() {
        return consider_date;
    }

    /**
     * @param consider_date the consider_date to set
     */
    public void setConsiderDate(boolean consider_date) {
        this.consider_date = consider_date;
    }

    /**
     * @return the consider_purpose
     */
    public boolean considerPurpose() {
        return consider_purpose;
    }

    /**
     * @param consider_purpose the consider_purpose to set
     */
    public void setConsiderPurpose(boolean consider_purpose) {
        this.consider_purpose = consider_purpose;
    }

    /**
     * @return the consider_item
     */
    public ItemSearchOptions considerItem() {
        return consider_item;
    }

    /**
     * @param consider_item the consider_item to set
     */
    public void setConsiderItem(ItemSearchOptions consider_item) {
        this.consider_item = consider_item;
    }

    /**
     * @return the consider_person
     */
    public PersonSearchOptions considerPerson() {
        return consider_person;
    }

    /**
     * @param consider_person the consider_person to set
     */
    public void setConsiderPerson(PersonSearchOptions consider_person) {
        this.consider_person = consider_person;
    }

    @Override
    public void reset() {
        setConsiderDate(false);
        setConsiderId(false);
        setConsiderItem(null);
        setConsiderPerson(null);
        setConsiderPurpose(false);
        setConsiderType(false);
    }

    public String getTransactionOrderString() {
        String order = "";
        if (consider_date)
            order += " order by transaction.date ";
        else if (consider_id)
            order += " order by transaction.id ";
        else if (consider_purpose)
            order += " order by transaction.purpose ";
        else if (consider_type)
            order += " order by transaction.type ";
        else if (consider_person != null)
            order += " order by transaction.person ";
        else if (consider_item != null)
            order += " and transaction.id = counts.transaction order by counts.items ";
        return order;
    }

    public boolean transactionOrderSpecified() {
        return consider_date ^ consider_id ^ consider_purpose ^ consider_type ^ consider_person != null ^ consider_item != null;
    }

    public boolean transactionOptionsSpecified() {
        return consider_date || consider_id || consider_purpose || consider_type || consider_person != null || consider_item != null;
    }

}
